<?php	
    require_once('recaptchalib.php'); // reCAPTCHA Library
    $success = ''; $failed=''; unset($data);
    $privkey = "6Lf14OcSAAAAAOUhyMyh31ZW_NUjGkxWKScuFuVu"; // Private API Key
    $verify = recaptcha_check_answer($privkey, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);

    if ($verify->is_valid) {
      # Enter Success Code
        if(isset($_POST['data'])){
            $data = $_POST['data'];
            unset($_POST['data']);
        }
      $success = "Your response was correct!";
    }
    else if(isset($_POST['recaptcha_challenge_field'])) {
      # Enter Failure Code
      $failed = "You did not enter the correct words.  Please try again.";
    }
?>
<?php
get_header(); 
$option = get_option('kkfashion_1_settings');
 ?>
<?php
    if(isset($data)){
        $html = '================================<br/>';
        $html.='<b><u>Họ tên:</u></b> '.$data['name'].'<br/>';
        $html.='<b><u>Email:</u></b> '.$data['email'].'<br/>';
        $html.='<b><u>Điện thoại:</u></b> '.$data['phone'].'<br/>';
        $html.='<b><u>Tiêu đề:</u></b> '.$data['subject'].'<br/>';
        $html.='<b><u>Nội dung liên lạc:</u></b> '.$data['message'].'<br/>';
        $html.= '================================';
        $current_site = get_bloginfo('name');
        add_filter( 'wp_mail_content_type', 'set_html_content_type' );
        wp_mail($option['email_contact'], 'Liên hệ từ khách hàng của '.$current_site, $html);
        remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
        $success = 'Your message was sent successfully!';
    }
?>
 <script type="text/javascript">
    $('.header').addClass('contact');
</script>
<script src="<?php echo bloginfo('template_url'); ?>/js/jquery-migrate-1.2.1.js"></script>
        <div class="row">
	    		<div class="col-12 header-description">
	    			<div class="title step">
                        <div class="line_1">Liên hệ</div>
                    </div>
                </div>
	    	</div>
	    </div>
    </div>
   
    <!-- Content -->
    <div class="main-content container">
    	<div class="row">
            <form class="form-horizontal" id="commentforms" action="" method="POST" onsubmit="return checkform()">
        		<div class="col-lg-6 col-12">
                  <div class="col-12">Vui lòng điền các thông tin sau<br/><br/></div>
                  <div class="form-group">
                    <label for="inputName" class="col-lg-3 col-sm-4 control-label hidden-sm">Họ tên (*)</label>
                    <div class="col-lg-9 col-sm-8">
                      <input name="data[name]" type="text" class="form-control input-small required" id="inputName" placeholder="Họ tên *">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputEmail" class="col-lg-3 col-sm-4 control-label hidden-sm">Email (*)</label>
                    <div class="col-lg-9 col-sm-8">
                      <input name="data[email]" type="text" class="form-control input-small required" id="inputEmail" placeholder="Email *">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputPhone" class="col-lg-3 col-sm-4 control-label hidden-sm">Điện thoại (*)</label>
                    <div class="col-lg-9 col-sm-8">
                      <input name="data[phone]" type="text" class="form-control input-small required" id="inputPhone" placeholder="Điện thoại *">
                    </div>
                  </div>
                  <div class="col-12"><i>(*) Bắt buộc nhập</i><br/><br/></div>
                </div>
                <div class="clearfix"></div>
                <div class="col-lg-6 col-12">
                  <div class="form-group">
                    <label for="inputTitle" class="col-lg-3 col-sm-4 control-label hidden-sm">Tiêu đề (*)</label>
                    <div class="col-lg-9 col-sm-8">
                      <input name="data[subject]" type="text" class="form-control input-small required" id="inputTitle" placeholder="Tiêu đề *">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputMessage" class="col-lg-3 col-sm-4 control-label hidden-sm">Nội dung</label>
                    <div class="col-lg-9 col-sm-8">
                      <textarea name="data[message]" class="form-control input-small" id="inputMessage" placeholder="Nội dung" rows="6"></textarea>
                    </div>
                  </div>
                </div>
                <div class="col-lg-6 col-12">
                    <div class="form-group">
                        <label for="inputCaptcha" class="col-lg-3 col-sm-4 control-label">Mã xác thực</label>
                        <div class="col-lg-9 col-sm-8">
                          <p>
                            <?php
                            $pubkey = "6Lf14OcSAAAAAD2IEZNAv0PWyF6ifXoLh_araaY3"; // Public API Key
                            echo recaptcha_get_html($pubkey); // Display reCAPTCHA
                            ?>
                          </p>
                          <?php if(!empty($success)){ ?>
                          <p style="color:green;"><?php echo $success ?></p>
                          <?php } ?>
                          <?php if(!empty($failed)){ ?>
                          <p style="color:red;"><?php echo $failed ?></p>
                          <?php } ?>
                           <script type="text/javascript">
                                function checkform(){
                                    var required = $('#commentforms .required');
                                    for(var i=0;i<required.length;i++){
                                        var each = required[i];
                                         if($(each).val()==''){
                                            alert('Please fill '+$(each).attr('placeholder')+'!');
                                            $(each).focus();
                                            return false;
                                        }
                                    }
                                }
                            </script>
                          <button type="submit" class="btn btn-custom">Gửi</button>
                        </div>
                      </div>
                </div>
            </form>
    	</div>
        <div class="row">
            <div class="contact-page">
                <p class="contact-name">K&K FASHION</p>

                <p>
                    <span>Showroom 1:</span> 268 TÔ HIẾN THÀNH, P. 15, QUẬN 10
                    <br /><span>Showroom 2:</span> 252 PHAN ĐÌNH PHÙNG, P.1, QUẬN PN, - TP. HỒ CHÍ MINH
                    <br /><span>Showroom 3:</span> 78 TRẦN QUANG DIỆU P.14 QUẬN 3 - TP. HỒ CHÍ MINH
                    <br /><span>Showroom 4:</span> 259 NGUYỄN TRÃI P.NGUYỄN CƯ TRINH QUẬN 1 - TP. HỒ CHÍ MINH
                </p>
                <p>
                    Điện thoại: <span>(08) 62.66.22.33</span> - Hotline: <span>(08) 62.66.22.33</span>    Fax: <span>(08)54.050.020</span>
                    <br />Email: <a href="#">sales@kkfashion.vn</a>
                    <br />Website: <a href="#">www.kkfashion.vn</a>
                </p>
            </div>
            <style type="text/css">
            	/* Bootstrap Css Map Fix*/
            	.google-map{
            		width: 100%;
            	}
				.google-map img { 
				max-width: none;
				}
				/* Bootstrap Css Map Fix*/
				.google-map label { 
				width: auto; display:inline; 
				}
				.contact-maps .img-thumbnail{
					width: 100%;
					margin-bottom: 10px;
				}
                #recaptcha_privacy{
                    display: none;
                }
            </style>
    		<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
    		<script src="<?php echo bloginfo('template_url'); ?>/js/jquery.gmaps.min.js"></script>
            <div class="contact-maps clearfix">
                <div class="col-lg-6">
				      <div class="img-thumbnail"><div id="googlemaps-1" class="google-map" style="height:400px;"></div></div>
				      <script type="text/javascript">
				        jQuery('#googlemaps-1').gMap({
				          maptype: 'ROADMAP',
				          scrollwheel: false,
				          zoom: 14,
				          markers: [
				            {
				              address: '268 TÔ HIẾN THÀNH, P. 15, QUẬN 10, Ho Chi Minh, Viet Nam', // Your Adress Here
				              html: '',
				              popup: false,
				            }
				          ],
				        });
				      </script>
                </div>
                <div class="col-lg-6">
                     <div class="img-thumbnail"><div id="googlemaps-2" class="google-map" style="height:400px;"></div></div>
				      <script type="text/javascript">
				        jQuery('#googlemaps-2').gMap({
				          maptype: 'ROADMAP',
				          scrollwheel: false,
				          zoom: 14,
				          markers: [
				            {
				              address: '252 PHAN ĐÌNH PHÙNG, P.1, QUẬN PHÚ NHUẬN, Ho Chi Minh, Viet Nam', // Your Adress Here
				              html: '',
				              popup: false,
				            }
				          ],
				        });
				      </script>
                </div>
                <div class="col-lg-6">
                     <div class="img-thumbnail"><div id="googlemaps-3" class="google-map" style="height:400px;"></div></div>
				      <script type="text/javascript">
				        jQuery('#googlemaps-3').gMap({
				          maptype: 'ROADMAP',
				          scrollwheel: false,
				          zoom: 14,
				          markers: [
				            {
				              address: '78 TRẦN QUANG DIỆU P.14, QUẬN 3, Ho Chi Minh, Viet Nam', // Your Adress Here
				              html: '',
				              popup: false,
				            }
				          ],
				        });
				      </script>
                </div>
                <div class="col-lg-6">
                     <div class="img-thumbnail"><div id="googlemaps-4" class="google-map" style="height:400px;"></div></div>
				      <script type="text/javascript">
				        jQuery('#googlemaps-4').gMap({
				          maptype: 'ROADMAP',
				          scrollwheel: false,
				          zoom: 14,
				          markers: [
				            {
				              address: '259 NGUYỄN TRÃI P.NGUYỄN CƯ TRINH, QUẬN 1, Ho Chi Minh, Viet Nam', // Your Adress Here
				              html: '',
				              popup: false,
				            }
				          ],
				        });
				      </script>
                </div>
            </div>
        </div>
    </div>
    <!-- End Content -->

<?php get_footer() ?>
